#!/usr/bin/env python
# -*- coding:utf-8 -*-

import wx
from docxtpl import DocxTemplate
import sys, os
class outputer():
    def __init__(self, test, dst):
        self.test = test
        self.dst = dst
    def messAlert(self):
        dlg = wx.MessageDialog(None, u"请确保计算结果正确", u"输出有误", wx.OK | wx.ICON_ERROR)
        if dlg.ShowModal() == wx.ID_YES:
            dlg.Destroy()
    def output(self):
        if self.test[0] == 'N/A':
            self.messAlert()
        else:

            # os.path.join(self.dst,u'超声检测指导书.docx')
            doc = DocxTemplate(u"test.docx")

            context = {'sk': self.test[0], 'jc':self.test[1], 'tt':self.test[2]}
            doc.render(context)
            doc.save(os.path.join(self.dst,u'超声检测指导书.docx'))